package de.graph.common.impl;

import de.graph.common.Edge;
import de.graph.common.Vertex;
import de.graph.document.Document;
import de.graph.document.DocumentFactory;

final class EdgeFactory {
	
    private EdgeFactory() {
	}

	public static final Edge create(final Vertex source, final Vertex target, boolean isDirected, final String label) {

        Document document = DocumentFactory.create();
        
        document.setProperty(EdgeImpl.SOURCE, source);
        document.setProperty(EdgeImpl.TARGET, target);
        
        if (label != null && label.length() > 0) {
            document.setProperty(EdgeImpl.LABEL, label);
        }
        
        if (!isDirected) {
            document.setProperty(EdgeImpl.IS_DIRECTED, isDirected);
        }
        
        return new EdgeImpl(document);
    }
}
